package com.sky.controller.user;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController("userShopController")
@RequestMapping("/user/shop")
public class ShopController {
    public static final String KEY="SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping("/status")
    public Result<Integer> getStatus(){
        Integer status=(Integer)redisTemplate.opsForValue().get(KEY);
        if (status == null) {
            // 如果Redis中没有设置营业状态，默认为打烊状态(0)或者返回特定值
            status = 0; // 或者可以根据业务需求设置默认值
        }
        log.info("营业状态为{}",status==1?"营业":"打烊");
        return Result.success(status);
    }
}
